D1.2 rotation primitives + taxonomy/ladder/shader-vs-engine epiphanies (95/95 tests)#234
Merged
Merged
Conversation
First real kernel deliverable of Phase 1: RotationKernel trait + three
impls (Identity / Hadamard / OPQ-stub) with typed RotationError.
95/95 cognitive-shader-driver tests pass under --features serve
(+15 new D1.2 tests).
crates/cognitive-shader-driver/src/rotation_kernel.rs (~330 LOC):
RotationKernel trait — object-safe, Send+Sync+Debug:
apply(&self, &mut [f32]) -> Result<(), RotationError>
dim() -> u32
signature() -> u64 # feeds CodecParams::kernel_signature
backend() -> &'static str # "avx512" | "stub" (never "scalar")
IdentityRotation { dim }
— zero-overhead pass-through; apply() is a no-op
HadamardRotation { dim }
— REAL in-place Sylvester butterfly, O(N log N) add/sub,
no allocations
— validates dim is power-of-two (Sylvester requirement)
— Rule C compliance: stays at Tier-3 F32x16 (add/sub, not matmul;
AMX adds no value per plan appendix §12 C)
— rustc + target-cpu=x86-64-v4 already emits AVX-512 add/sub
from the straight-line loop → no JIT compilation needed
OpqRotationStub { matrix_blob_id, dim }
— real impl plugs into D1.1b CodecKernelEngine adapter +
ndarray::hpc::jitson_cranelift::JitEngine + tile_dpbf16ps AMX
matmul when amx_available()
— apply() returns OpqMatrixNotLoaded (typed error) until the
matrix-blob loader lands
build(&Rotation, dim) -> Result<Box<dyn RotationKernel>> factory
— dispatches on WireCodecParams.pre_rotation variant
— returns typed errors on dim mismatch or non-pow2 Hadamard
Tests (15 new):
Identity: noop + dim-mismatch error
Hadamard:
- orthogonality: H_4 · [1,0,0,0] == [1,1,1,1] (first column)
- H · H = n · I (applying twice scales by n, verified at N=8)
- norm² preservation up to n× scale (verified at N=16)
- rejects non-pow2 dim (N=6)
OPQ stub: returns OpqMatrixNotLoaded with blob_id preserved
build(): identity / hadamard / hadamard-dim-mismatch / hadamard-
non-pow2 / opq-stub
Signatures: distinct across variants, stable for same shape,
blob-id-sensitive for OPQ
Board hygiene (CLAUDE.md Mandatory rule):
STATUS_BOARD.md:
D1.2 Queued → In PR
EPIPHANIES.md PREPEND (two entries):
1. "Thinking styles ARE codecs over the semantic field"
(north-star forward-looking deposit, not a work item)
— codec infrastructure IS the template for production-grade
thinking tissue. Mapping table documents the codec→thinking
correspondence: CodecParams↔ThinkingStyleParams,
kernel_signature↔style_signature, token_agreement↔
conclusion_agreement, etc. Phase 5+ drops in
WireThinkCalibrate + ThinkingStyleKernelCache using the
same scaffolding. Generalisation isn't porting — it's
recognising thinking styles as a SPECIAL CASE of the
codec pattern.
2. "D1.2 Hadamard is pure-Rust, not a JIT-necessary primitive"
— narrows D1.1b scope by 30-40%. Only OPQ (matmul) needs
Cranelift JIT emission; Identity (no-op) and Hadamard
(butterfly) stay as plain-Rust Tier-3 F32x16 paths. Rustc's
AVX-512 codegen under target-cpu=x86-64-v4 is already
optimal for add/sub-structured kernels.
Rules honored:
Rule A — in-place &mut [f32] slice, no allocations in apply()
Rule B — ndarray::simd::* not needed for these shapes; compiler
emits AVX-512 from straight-line loops
Rule C — Hadamard stays at Tier 3 (add/sub, no AMX benefit);
OPQ stub will route to Tier 1 AMX when matrix loaded
Rule D — Rotation variants come from YAML via WireRotation (D0.1)
Rule E — kernel signature() + backend() are object-methods per
the Wire-surface-IS-SIMD-surface pattern
Rule F — no serialization anywhere; in-memory f32 buffer only
https://claude.ai/code/session_01SbYsmmbPf9YQuYbHZN52Zh
…sue taxonomy
Three related forward-looking deposits from this session's strategic
thread (codec IS thinking at scale → thinking-styles are codecs over
the semantic field → cognitive shader vs thinking engine boundary):
1. Thinking styles ARE codecs over the semantic field (north star).
The codec infrastructure IS the template for production-grade
thinking tissue. Codec → thinking-style mapping:
CodecParams ↔ ThinkingStyleParams
kernel_signature ↔ style_signature
CodecKernelCache<H> ↔ ThinkingStyleKernelCache<H>
token_agreement ↔ conclusion_agreement
Generalisation isn't porting — it's recognising thinking styles
as a SPECIAL CASE of the codec pattern.
2. Resolution ladder 64×64 > 256×257 >> 4096×4096 > 16k (user-named).
The 5-layer stack is a resolution ladder, not a layer cake:
64×64 — p64 topology mask (HEEL)
256×257 — bgz17 palette distance (HIP)
4096×4096 — cross-vocab / cross-context (BRANCH/TWIG)
16 K — Fingerprint<256> identity (LEAF)
The `>>` between 256×257 and 4096×4096 is the big jump — where
palette-level meets vocabulary-level. Each JIT targets its own
resolution, no overlap. p64::CognitiveShader operates at
coarsest (64×64); codec-sweep D1.x at finest (16k); they compose
in cognitive-shader-driver::ShaderDriver. p64 double-check:
architecturally clean, no reimplementation in my work.
3. Shader vs engine: statelessness is the boundary.
Cognitive shader = stateless atomic compute (eye — reports
current frame, no memory).
Thinking engine = stateful orchestrator (mind — assembles frames
into narrative, carries persona/qualia/world_model across cycles).
engine_bridge.rs is the seam. Codec-flexibility-as-thinking lands
at the ENGINE level, not shader level — D5/Phase 5+ drops into
thinking-engine mid-layer.
All three epiphanies are forward-looking deposits (not current work
items). They clarify where future work lands when codec-sweep Phase 1
completes and Phase 5+ generalises.
Cross-references:
- I10 HEEL/HIP/BRANCH/TWIG/LEAF (LATEST_STATE.md)
- I5 thinking IS AdjacencyStore
- p64_bridge::cognitive_shader::CognitiveShader (64×64 cascade)
- thinking-engine crate structure (CLAUDE.md)
https://claude.ai/code/session_01SbYsmmbPf9YQuYbHZN52Zh
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Second Phase 1 kernel deliverable + three strategic epiphanies from this session's "codec IS thinking" thread.
95/95
cognitive-shader-driver --features servetests pass (+15 new D1.2 tests).D1.2 — Rotation primitives (
5c37f0c)crates/cognitive-shader-driver/src/rotation_kernel.rs— ~330 LOC, 15 tests.Key detail — Hadamard is pure Rust, not JIT-necessary. The Sylvester butterfly is a fixed-shape add/sub pattern; rustc under
target-cpu=x86-64-v4already emits AVX-512 from the straight-line loop. Per Rule C (polyfill hierarchy), add/sub stays at Tier 3 F32x16 — AMX gives no benefit here. This narrows D1.1b Cranelift scope by 30-40%: only OPQ (matmul) needs JIT emission; Identity and Hadamard stay as plain Rust.Tests verify:
H_4 · [1,0,0,0] == [1,1,1,1](first column)H · H = n · Iat N=8 (applying twice scales by n)OpqMatrixNotLoadedbuild()routes correctly for all three variantsThree forward-looking epiphanies (
aad6e6a)APPEND-ONLY on
EPIPHANIES.md— not current work items, forward-looking deposits for Phase 5+.1. Thinking styles ARE codecs over the semantic field
The codec infrastructure IS the template for production-grade thinking tissue. Mapping:
CodecParamsThinkingStyleParamskernel_signature()style_signature()CodecKernelCache<H>ThinkingStyleKernelCache<H>Generalisation isn't porting — it's recognising thinking styles as a special case of the codec pattern.
2. Resolution ladder:
64×64 > 256×257 >> 4096×4096 > 16k(user-named)The 5-layer stack is a resolution ladder, not a layer cake:
p64_bridge::cognitive_shader::CognitiveShader)semiring.distance)ScanParamsJIT)Fingerprint<256>bit identity (codec decoder)The
>>between 256×257 and 4096×4096 is the big jump (~64×) — where palette-level meets vocabulary-level. Each JIT targets its own resolution; no overlap.p64 double-check conclusion:
p64_bridge::cognitive_shader::CognitiveShaderat 64×64 is architecturally clean; my D1.x codec work at 16K is at a different layer of the ladder; they compose incognitive_shader_driver::ShaderDriver.3. Shader vs engine: statelessness is the boundary
Cognitive shader = stateless atomic compute (eye — reports current frame, no memory).
Thinking engine = stateful orchestrator (mind — assembles frames, carries persona/qualia/world_model).
engine_bridge.rsis the seam. Codec-flexibility-as-thinking lands at the engine level, not shader level — D5/Phase 5+ drops into thinking-engine mid-layer.Board hygiene (same commit per Mandatory rule)
STATUS_BOARD.md: D1.2 Queued → In PREPIPHANIES.md: 3 PREPEND entries (taxonomy + ladder + shader/engine)Test Plan
cargo test --manifest-path crates/cognitive-shader-driver/Cargo.toml --features serve --lib— 95/95 pass (+15 new)cargo test -p lance-graph-contract --lib— 147/147 pass (unchanged)cargo test --manifest-path crates/jc/Cargo.toml— 6/6 pass (JC substrate proof unchanged)https://claude.ai/code/session_01SbYsmmbPf9YQuYbHZN52Zh